# Contributor: Dhruvin Gandhi <contact@dhruvin.dev>
# Maintainer: Dhruvin Gandhi <contact@dhruvin.dev>
pkgname=hledger-web
pkgver=1.26
pkgrel=0
pkgdesc="Web interface for the hledger accounting system"
url="https://hledger.org/hledger-web.html"
arch="x86_64" # limited by ghc
license="GPL-3.0-only"
makedepends="ghc cabal libffi-dev ncurses-dev zlib-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://hackage.haskell.org/package/hledger-web-$pkgver/hledger-web-$pkgver.tar.gz
	cabal.project.freeze
	hledger-web.initd"
install="$pkgname.pre-install"

export CABAL_DIR="$srcdir"/cabal

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

check() {
	cabal test
}

package() {
	local ghcver=$(ghc --version | cut -d " " -f 8)
	install -Dm755 \
		"dist-newstyle/build/$arch-linux/ghc-$ghcver/$pkgname-$pkgver/x/$pkgname/build/$pkgname/$pkgname" \
		"$pkgdir"/usr/bin/$pkgname
	install -Dm644 $pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
7d497c6ea3dc34a527a8855e0f7e5ea404fa86b3012767fc6a96705acd84aa9c3a09ab76793ad56762dfbe8e0db890d3121ab48113f96f32263ca6fdf7a6c108  hledger-web-1.26.tar.gz
b69dfc542133d3a79a33353ee52c37b0318b3ce5853993098ab0962b2b8ce52a0722b2a003983edb8f958f618531a8853990d77382cc5b489a05682c0b72c90b  cabal.project.freeze
4fd0898b29736c1d7f5b41b1ccca8734f38999e5ba88656e092724a7ce4ed346b4f86d627c99be77934eaa7cd86e33ce20a33a60650f1ad8a527c57387179365  hledger-web.initd
"
